﻿@model BuySoftwareOnline.Domain.Product

@{
    ViewBag.Title = "Admin: Edit " + @Model.ProductName;
}


<b>Edit @Model.ProductName</b>
@using (Html.BeginForm("Edit", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    <b>ProductID</b>
    <br />
    @Html.EditorFor(p => p.ProductID)
    @Html.ValidationMessageFor(p => p.ProductID)
    <br />
    <b>ProductName</b>
    <br />
    @Html.EditorFor(p => p.ProductName)
    @Html.ValidationMessageFor(p => p.ProductName)
    <br />
    <b>Description</b>
    <br />
    @Html.EditorFor(p => p.Description)
    @Html.ValidationMessageFor(p => p.Description)
    <br />
    <b>Content</b>
    <br />
    @Html.EditorFor(p => p.Content)
    @Html.ValidationMessageFor(p => p.Content)
    <br />
    <b>Requirement</b>
    <br />
    @Html.EditorFor(p => p.Requirement)
    @Html.ValidationMessageFor(p => p.Requirement)
    <br />
    <b>Size</b>
    <br />
    @Html.EditorFor(p => p.Size)
    @Html.ValidationMessageFor(p => p.Size)
    <br />
    <b>PlatForm</b>
    <br />
    @Html.EditorFor(p => p.PlatForm)
    @Html.ValidationMessageFor(p => p.PlatForm)
    <br />
    <b>UnitPrice</b>
    <br />
    @Html.EditorFor(p => p.UnitPrice)
    @Html.ValidationMessageFor(p => p.UnitPrice)
    <br />
    <b>Total</b>
    <br />
    @Html.EditorFor(p => p.Total)
    <br />
    <b>IsView</b>
    <br />
    @Html.EditorFor(p => p.IsView)
    <br />
    <b>Category</b>
    <br />
    <div class="editor-field">
        @Html.DropDownList("CategoryID", String.Empty)
        @Html.ValidationMessageFor(p => p.CategoryID)
    </div>
    <br />
     <b>Supplier</b>
    <br />
    <div class="editor-field">
        @Html.DropDownList("SupplierID", String.Empty)
        @Html.ValidationMessageFor(p => p.SupplierID)
    </div>
    <div class="editor-label">Image</div>
        <div class="editor-field">
        @if (Model.ImageContent == null)
        {
            @:None
        }
        else
        {
            <img alt="image" width="150" height="150" src="@Url.Action("GetImage", "Product", new { Model.ProductID })" />
        }
        <div>Upload new image: <input type="file" name="file[0]" /></div>
    </div>
     <div class="editor-label">Screenshot</div>
        <div class="editor-field">
        @if (Model.ScreenShot == null)
        {
            @:None
        }
        else
        {
            <img alt="screenshot" width="150" height="150" src="@Url.Action("GetScreenShot", "Product", new { Model.ProductID })" />
        }
        <div>Upload new screenshot: <input type="file" name="file[1]" /></div>
    </div>
    <div class="editor-field">
        <table style="width: 100%">
            <tr>
            @{
        int count = 0;
        List<BuySoftwareOnline.Web.Models.AssignedVersionData> versions = ViewBag.Versions;
        foreach (var version in versions)
        {
            if (count++ % 3 == 0)
            {
                        @: </tr> <tr>
                    }
                    @: <td>
                    if (version.VersionType == "Home")
                    {
                        <input type="checkbox" name="selectedVersions" value="@version.VersionID" checked="checked" onclick="this.checked=!this.checked;" />
                        @version.VersionType @:&nbsp;+<input name="AddPrice@(version.VersionID)" type="text" size="2" maxlength="3" value="@version.AddPrice.ToString("0")" disabled="disabled" />
                    }
                    else
                    {
                        <input type="checkbox" name="selectedVersions" value="@version.VersionID" @(Html.Raw(version.Assigned ? "checked=\"checked\"" : "")) />
                        @version.VersionType @:&nbsp;+<input name="AddPrice@(version.VersionID)" type="text" size="2" maxlength="3" value="@version.AddPrice.ToString("0")"/>
                    }
                    @: </td>
                }
                @:</tr>
            }
           
        </table>
    </div>
    <input type="submit" value="Save" />
    @Html.ActionLink("Cancel and return to List", "Index")
}
